<?xml version="1.0" encoding="UTF-8" ?>
<%@ page import="org.swimv2.model.Persona" %>
<%@ page import="org.swimv2.model.Abilita" %>
<%@ page import="org.swimv2.model.Feedback" %>
<%@ page import="java.util.List" %>
<%@page import="landmark.LandmarkUtente"%>
<%@page import="landmark.Link"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Profilo</title>
<link rel="stylesheet" type="text/css" href="scheletro.css">
</head>
<body>
<div id="container">
<table class="topHome">
	<tr>
		    <td id="logoHome">
	<a href="home.jsp">Swim v2</a>
	<br><br><b> A help with a click!</b>

		    </td>
			<td class="personal">
		
				<b>Ciao :<a href="PaginaProfiloServlet">${sessionScope.utente.nome}</a> </b>&nbsp;&nbsp;&nbsp;<a href="Notifiche"><b>Interazioni</b></a>&nbsp;<a href="messaggi.jsp"><b>Messaggi</b></a>&nbsp;&nbsp;&nbsp;<div id="button"><a href="Logout" id="logout">Logout</a></div>

			</td>		
	</tr>
</table>

<div id="nav"> 
	<ul>
		<%
			Link a[]  = LandmarkUtente.getLandmark();
			for(int i=0; i<a.length; i++)
			{
		%>
			<li><a href="<%=a[i].getHref()%>"><%=a[i].getValue()%></a></li>
		<%
			}
		%>
	</ul>
</div>

<div id="form">
  <%
  	@SuppressWarnings("unchecked")
    	Persona u=(Persona) request.getSession().getAttribute("utente");
  %>	
	 
<div id="titlePage"><h1><%out.print(u.getNome()+" "+u.getCognome());%></h1></div><br><br><br><br>	 
	 <img id="foto" src="img/fotoProfilo" width="180px" height="180px" /> 
	
	<b>E-mail dell'utente: </b><a href="mailto:<%=u.getE_mail() %>"><%=u.getE_mail() %></a>
	<%
	@SuppressWarnings("unchecked")
		List<Abilita> ab = (List<Abilita>)request.getAttribute("listAb");
	%>
		<br><br><b>Abilità</b><br>
		  <ul>
			<%
				if(ab!=null && ab.size()>0){
				for(Abilita abi:ab){
			%>
			<li>
				<%out.print(abi.getNome());
				%>
			</li>
			<% }
				}
				%>	
					</ul>
	<%  List <Feedback> feedbacks =(List<Feedback>)request.getAttribute("listFeedback"); 
	float media;
	float sommaFeedbacks=0;
	int numFeedbacks=0;
	if(feedbacks.size()>0)
	{
	numFeedbacks=feedbacks.size();
	
	
	for (Feedback f:feedbacks){
		sommaFeedbacks = sommaFeedbacks + f.getValutazione_num_();
	}
	media=sommaFeedbacks/numFeedbacks;
	
	}else{
	media=0;
	}
%>
<br><br><b>Regione:</b> &nbsp;<%
out.print(u.getRegione());
%>
<br><br><b>Feedback(voto medio):</b> &nbsp;<%
out.print(media + " su " + numFeedbacks + " feedbacks ricevuti.");
%>
	<br><br><b>Stato disponibilità:</b> &nbsp;<%
 	out.print(u.getDisponibilita()); %>
</div>

</div>	
</body>
</html>